package realQuestion.dajiang;

import java.util.*;

public class Solution1 {
    /* Write Code Here */
    public int[] ThreeDigitNumbers (int[] selectedDigits) {
        Arrays.sort(selectedDigits);
  List<Integer>  res1=new ArrayList<>();
  gen1(selectedDigits,new boolean[selectedDigits.length],new int[3],0,res1);
        for (int a: res1
             ) {
            System.out.println(a+"");

        }
        int[] res = new int[res1.size()];
        for (int i = 0; i < res1.size(); i++) {
            res[i]= res1.get(i);
        }

        System.out.println(res.length);
        return res;

    }

    public   void gen1(int[] nums1,boolean[] visited,int[] nums2,int level,List<Integer> res1){
//       List<List<Integer>>   res = new ArrayList<>();
//        int[] indexes = new int[3];
        if (level==3){
            int num=nums2[0]*100+nums2[1]*10+nums2[2];
            res1.add(num);
            return;
        }
        for (int i = 0; i < nums1.length; i++) {
            if (!visited[i]){
                visited[i]=true;
                nums2[level]=nums1[i];
                gen1(nums1, visited, nums2, level+1, res1);
                visited[i]=false;
            }
        }

    }
}

class Main {
    public static void main(String[] args){
//        Scanner in = new Scanner(System.in);
//        int[] res;
//        int selectedDigits_size = 0;
//        selectedDigits_size = in.nextInt();
//        int[] selectedDigits = new int[selectedDigits_size];
//        for(int selectedDigits_i = 0; selectedDigits_i < selectedDigits_size; selectedDigits_i++) {
//            selectedDigits[selectedDigits_i] = in.nextInt();
//        }
//
//        if(in.hasNextLine()) {
//            in.nextLine();
//        }
//
//        res = new Solution1().ThreeDigitNumbers (selectedDigits);
//        for(int res_i=0; res_i < res.length; res_i++) {
//            System.out.println(String.valueOf(res[res_i]));
//        }
        int[] arr={1,2,3,4,5};
        Solution1 solution1 = new Solution1();
        solution1.ThreeDigitNumbers(arr);


    }
}